#include<ros/ros.h>
#include<tf2_ros/static_transform_broadcaster.h>
#include<tf2/LinearMath/Quaternion.h>

int main(int argc, char *argv[])
{   
    setlocale(LC_ALL,"");
    ros::init(argc,argv,"static_pub");

    ros::NodeHandle nh;

    tf2_ros::StaticTransformBroadcaster pub;


    geometry_msgs::TransformStamped tfs;
    tfs.header.stamp = ros::Time::now();

    tfs.header.frame_id = "base_link"; //相对被参考的那个

    tfs.child_frame_id = "laser";

    tfs.transform.translation.x = 0.2;
    tfs.transform.translation.y = 0.0;
    tfs.transform.translation.z = 0.5;
    //需要参考欧拉角
    tf2::Quaternion qtn;  //创建四元数对象

    //向该对象设置欧拉角 可以将欧拉角转化成四元数

    qtn.setRPY(0,0,0); //欧拉角单位 弧度

    tfs.transform.rotation.x = qtn.getX();
    tfs.transform.rotation.y = qtn.getZ();
    tfs.transform.rotation.z = qtn.getY();
    tfs.transform.rotation.w = qtn.getW();
    //发布数据
    pub.sendTransform(tfs);

    ros::spin();

    return 0;



    
    return 0;
}
